package com.six.apidemic.activity;


import android.graphics.Bitmap;
import android.os.Bundle;

import androidx.databinding.DataBindingUtil;

import com.google.zxing.Result;
import com.google.zxing.client.result.ParsedResult;
import com.mylhyl.zxing.scanner.OnScannerCompletionListener;
import com.six.apidemic.R;
import com.six.apidemic.databinding.ActivityScannerBinding;
import com.six.apidemic.util.LogUtils;

/**
 * 二维码相关界面
 * @author Administrator
 */
public class ScannerActivity extends BaseActivity{

    ActivityScannerBinding binding;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = DataBindingUtil.setContentView(this,R.layout.activity_scanner);
        binding.setActivity(this);
        initView();
        initData();
    }

    protected void initView() {
        binding.scannerView.setOnScannerCompletionListener(new OnScannerCompletionListener() {
            /**
             * 扫描成功后将调用
             *
             * @param rawResult    扫描结果
             * @param parsedResult 结果类型
             * @param barcode      扫描后的图像
             */
            @Override
            public void onScannerCompletion(Result rawResult, ParsedResult parsedResult, Bitmap barcode) {
                LogUtils.e("扫描结果-->" +rawResult.getText());
            }
        });
    }

    protected void initData() {

    }

    @Override
    protected void onResume() {
        binding.scannerView.onResume();
        super.onResume();
    }

    @Override
    protected void onPause() {
        binding.scannerView.onPause();
        super.onPause();
    }
}
